package com.cy.pj.common.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
/**
 * @author Cx
 * @stage secondStageOfWeb
 * @creat 2020-11-12 9:42
 */
@Aspect
@Component
public class SysLogAspect {

    @Pointcut("bean(categoryServiceImpl)") /* @Pointcut切入点定义 */
    public void doLog() {
    } /* 此方法作用是承载切入点 不需要任何内容 */

    @Around("doLog()")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        long start = System.currentTimeMillis();
        Object result = joinPoint.proceed();
        long end = System.currentTimeMillis();
        System.out.println("execute time : " + (end - start));
        return result;
    }

}
